package org.zcl.api;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * .
 *
 * @author zhuchenglin
 * @since 2024/4/22 16:10
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApiResponse<T> {

    private int code;

    private String msg;

    private T data;

    public ApiResponse<T> returnSuccess(int code, String msg, T data) {
        return new ApiResponse<>(code, msg, data);
    }

    public ApiResponse<T> returnSuccess(T data) {
        return new ApiResponse<>(200, "success", data);
    }

    public ApiResponse<T> returnFailure(String msg) {
        return new ApiResponse<>(500, msg, null);
    }
}
